<%--
  Created by IntelliJ IDEA.
  User: zjy
  Date: 2015/4/13
  Time: 16:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools"/>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:1px;">
    <t:datagrid name="tdIscenterList" title="" actionUrl="articleController.do?datagrid" idField="id"
                fit="true" queryMode="group" sortName="createTime" sortOrder="desc">
      <t:dgCol title="id" field="id" hidden="true"></t:dgCol>
      <t:dgCol title="attachmentId" field="tAttachment.attachmentId" hidden="true"></t:dgCol>
      <t:dgCol title="内容标题" field="title" query="true" ></t:dgCol>
      <t:dgCol title="内容副标题" field="subtitle"   ></t:dgCol>
      <t:dgCol title="分类标签" field="articleCateGoryName"   ></t:dgCol>
      <t:dgCol title="浏览量" field="reading"   ></t:dgCol>
      <t:dgCol title="是否发布" field="isPublish" dictionary="isno" query="true" ></t:dgCol>
      <t:dgCol title="发布时间" formatter="yyyy-MM-dd hh:mm:ss" field="publishTime"  ></t:dgCol>
      <t:dgCol title="发布平台" field="publishPlat"  dictionary="supportSys"></t:dgCol>
      <t:dgCol title="创建时间" formatter="yyyy-MM-dd hh:mm:ss" field="createTime"  ></t:dgCol>

      <t:dgCol title="common.operation" field="opt" ></t:dgCol>
      <t:dgDelOpt url="articleController.do?delArticle&id={id}" title="删除"></t:dgDelOpt>

      <t:dgToolBar title="新增" icon="icon-add" url="articleController.do?addorupdate" funname="add" width="800" height="600"></t:dgToolBar>
      <t:dgToolBar title="修改" icon="icon-edit" url="articleController.do?addorupdate" funname="update"  width="800" height="600"></t:dgToolBar>
      <t:dgToolBar title="发布通告" langArg="common.user" icon="icon-edit" url="articleController.do?publish" funname="publish" ></t:dgToolBar>
      <t:dgToolBar title="预览" langArg="common.user" icon="icon-search" url="articleController.do?preview&id=" funname="f_openPreview"  width="850" height="600"></t:dgToolBar>
      <%--<t:dgToolBar title="查看" icon="icon-search" url="sArticleController.do?addorupdate&search=search" funname="detail"  width="800" height="630"></t:dgToolBar>--%>
    </t:datagrid>
  </div>
</div>
<script type="text/javascript">


  function publish(title,url, id){
    gridname = id;
    var rowsData = $('#'+id).datagrid('getSelections');
    if (!rowsData || rowsData.length==0) {
      tip('请选择需要发布的条目');
      return;
    }
    url += '&id='+rowsData[0].id;

    $.dialog.confirm('确定要发布该文章吗？',
            //确定按钮回调函数
            function(){
              publishUploadIfy(url, '&id');
            },
            //取消按钮回调函数
            function(){
            }
    );
  }
  function publishUploadIfy(url, id){
    $.ajax({
      async : false,
      cache : false,
      type : 'POST',
      url : url,// 请求的action路径
      error : function() {// 请求失败处理函数

      },
      success : function(data) {
        var d = $.parseJSON(data);
        if (d.success) {
          var msg = d.msg;
          tip(msg);
          reloadTable();
        }
      }
    });
  }


  function f_openPreview(title,url,gname,width,height){


    var rowsData = $('#'+gname).datagrid('getSelections');
    if (!rowsData || rowsData.length==0) {
    tip('请选择要预览的公告');
    return;
    }
    if (rowsData.length>1) {
    tip('请选择一条记录预览');
    return;
    }

    url += rowsData[0].id;

    openwindow(title + "[" + rowsData[0].title + "]", url ,gname,width,height);

  }
</script>
